#include "Question.h"
#include <string>

Question::Question() {
	question = "";
	right_answer = "";
	point_right_answer = 0;
	student_answer = "";
	point_student_answer = 0;
}

Question::Question(std::string question, std::string right_answer, double point_right_answer,
	std::string student_answer = "", double point_student_answer = 0) 
{
	this->question = question;
	this->right_answer = right_answer;
	this->point_right_answer = point_right_answer;
	this->student_answer = student_answer;
	this->point_student_answer = point_student_answer;
}

bool Question::Check() {
	if (student_answer == right_answer) {
		point_student_answer = point_right_answer;
		return true;
	}

	else {
		point_student_answer = 0;
		return false;
	}
}

void Question::Read() {
	std::cout << std::endl << "Question: ";
	std::cin >> question;
	std::cout << std::endl << "Right answer: ";
	std::cin >> right_answer;
	std::cout << std::endl << "Points for right answer: ";
	std::cin >> point_right_answer;
	std::cout << std::endl << "Students answer: ";
	std::cin >> student_answer;
}

void Question::Write() {
	std::cout << "Question: " << question << std::endl << std::endl;
	std::cout << "Right answer: " << right_answer << std::endl << std::endl;
	std::cout << "Points for right answer: " << point_right_answer << std::endl << std::endl;
	std::cout << "Students answer: " << student_answer << std::endl << std::endl;
	std::cout << "Points for students answer: " << point_student_answer << std::endl << std::endl;
}

std::ostream& operator<<(std::ostream& o, const Question& question) {
	o << question.question << std::endl;
	o << question.right_answer << std::endl;
	o << question.point_right_answer << std::endl;
	o << question.student_answer << std::endl;
	o << question.point_student_answer << std::endl;

	return o;
}

std::istream& operator>>(std::istream& i, Question& question) {
	i >> question.question;
	i >> question.right_answer;
	i >> question.point_right_answer;
	i >> question.student_answer;
	i >> question.point_student_answer;

	return i;
}